package io.polly.thread;

import io.polly.common.entity.NotifyItem;
import lombok.Data;

import java.util.List;
import java.util.concurrent.*;

/**
 * @author ldz
 * @version V1.0
 * @title: DynamicExecutor
 * @description: TODO(用一句话描述该文件做什么)
 * @date: 2022/3/21 11:28
 */
@Data
public class DynamicExecutor extends ThreadPoolExecutor {


    private String threadPoolName;
    private List<NotifyItem> notifyItems;

    public DynamicExecutor(int corePoolSize,
                           int maximumPoolSize,
                           long keepAliveTime,
                           TimeUnit unit,
                           BlockingQueue<Runnable> workQueue,
                           ThreadFactory threadFactory,
                           RejectedExecutionHandler handler){
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
    }

    public int getQueueCapacity() {
        return getQueue().size() + getQueue().remainingCapacity();
    }

}
